$(document).ready(function(){  
	$('textarea').autosize();   

	$('.container-scroll').jscroll();

	$('.statistic-overview .button-statistic-group').click(function(e){
		e.preventDefault();
		var url = $('form#form-statistic-group').attr('action');
		var data = $('form#form-statistic-group').serialize();
		sendAjaxRequest(url, data);
	});
	

	$('.statistic-overview .button-statistic-parameter').click(function(e){
		e.preventDefault();
		var url = $('form#form-statistic-parameter').attr('action');
		var data = $('form#form-statistic-parameter').serialize();
		sendAjaxRequest(url, data);
	});
	
	
	$('.statistic-overview .button-statistic-value').click(function(e){
		e.preventDefault();
		var url = $('form#form-statistic-value').attr('action');
		var data = $('form#form-statistic-value').serialize();
		sendAjaxRequest(url, data);
	});

	
	function sendAjaxRequest(url, data){
		$('.content-message-text').html( 'Wird ausgeführt' );
		$('.content-message-text').slideDown();
		$.ajax({
			type: "POST",
			url: url,
			data: data
			}).done(function( msg ) {
				var msg = jQuery.parseJSON( msg );
				$('.content-message-text').html( msg.response );
				$('#form-statistic-group input').val('');
				setInterval(function() { $('.content-message-text').slideUp(); }, 5000);				
			}).fail(function( msg) {
				var msg = jQuery.parseJSON( msg );
				$('.content-message-text').html( msg.response );
				setInterval(function() { $('.content-message-text').slideUp(); }, 5000);
			});
	}

});



